package com.cskaoyan.mall.product.runner;

import com.cskaoyan.mall.product.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @Author Pudding
 * @Date 2024/7/15 16:36
 */
@Slf4j
@Component
public class StartupCategoryLoader implements ApplicationRunner {

    @Autowired
    CategoryService categoryService;

    @Override
    public void run(ApplicationArguments args) throws Exception {

        long start = System.currentTimeMillis();

        categoryService.getCategoryTreeList();

        long end = System.currentTimeMillis();

        log.info("加载商品分类树成功，耗时：{}ms", end - start);
    }
}
